<!doctype html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Maven 构建速度优化指南</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        /* Hero 区域样式 */
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            position: relative;
            overflow: hidden;
        }
        
        .hero-gradient::before {
            content: '';
            position: absolute;
            top: -50%;
            right: -50%;
            width: 200%;
            height: 200%;
            background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
            animation: float 20s ease-in-out infinite;
        }
        
        @keyframes float {
            0%, 100% { transform: translate(0, 0) rotate(0deg); }
            50% { transform: translate(-30px, -30px) rotate(180deg); }
        }
        
        /* 代码块样式 */
        pre {
            background: #1e293b;
            color: #e2e8f0;
            border-radius: 12px;
            padding: 1.5rem;
            overflow-x: auto;
            box-shadow: 0 10px 30px rgba(0,0,0,0.2);
            position: relative;
            margin: 1.5rem 0;
        }
        
        pre::before {
            content: attr(data-language);
            position: absolute;
            top: 0.5rem;
            right: 1rem;
            font-size: 0.75rem;
            color: #64748b;
            text-transform: uppercase;
            letter-spacing: 0.05em;
        }
        
        code {
            font-family: 'Fira Code', 'Consolas', monospace;
            font-size: 0.9rem;
            line-height: 1.6;
        }
        
        /* 内联代码样式 */
        .inline-code {
            background: #e0e7ff;
            color: #4338ca;
            padding: 0.125rem 0.375rem;
            border-radius: 0.25rem;
            font-family: 'Fira Code', 'Consolas', monospace;
            font-size: 0.875em;
        }
        
        /* 卡片悬停效果 */
        .feature-card {
            transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            background: white;
            border-radius: 16px;
            padding: 2rem;
            box-shadow: 0 4px 6px rgba(0,0,0,0.07);
        }
        
        .feature-card:hover {
            transform: translateY(-8px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.15);
        }
        
        /* 章节标题装饰 */
        .section-title {
            position: relative;
            padding-left: 1.5rem;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 100%;
            background: linear-gradient(180deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        /* 列表样式 */
        .custom-list li {
            position: relative;
            padding-left: 2rem;
            margin-bottom: 1rem;
        }
        
        .custom-list li::before {
            content: '\f00c';
            font-family: 'Font Awesome 6 Free';
            font-weight: 900;
            position: absolute;
            left: 0;
            top: 0.25rem;
            color: #667eea;
        }
        
        /* 首字下沉 */
        .drop-cap::first-letter {
            float: left;
            font-size: 4rem;
            line-height: 3rem;
            padding-right: 0.5rem;
            margin-top: 0.25rem;
            font-weight: 700;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        
        /* 滚动动画 */
        .fade-in {
            opacity: 0;
            transform: translateY(30px);
            transition: all 0.8s ease-out;
        }
        
        .fade-in.visible {
            opacity: 1;
            transform: translateY(0);
        }
        
        /* Mermaid 图表样式 */
        .mermaid {
            background: white;
            padding: 2rem;
            border-radius: 12px;
            box-shadow: 0 4px 20px rgba(0,0,0,0.1);
            margin: 2rem 0;
        }
    </style>
</head>
<body>
    <!-- Hero 区域 -->
    <div class="hero-gradient text-white py-20 px-6">
        <div class="max-w-6xl mx-auto text-center relative z-10">
            <h1 class="text-5xl md:text-6xl font-bold mb-6 tracking-tight">
                <i class="fas fa-rocket mr-4"></i>Maven 构建速度优化指南
            </h1>
            <p class="text-xl md:text-2xl opacity-90 max-w-3xl mx-auto leading-relaxed">
                让你的 Java 项目构建速度提升 300%，从此告别漫长等待
            </p>
            <div class="mt-10 flex justify-center space-x-8">
                <div class="text-center">
                    <div class="text-4xl font-bold">5x</div>
                    <div class="text-sm opacity-75">构建速度提升</div>
                </div>
                <div class="text-center">
                    <div class="text-4xl font-bold">80%</div>
                    <div class="text-sm opacity-75">等待时间减少</div>
                </div>
                <div class="text-center">
                    <div class="text-4xl font-bold">100%</div>
                    <div class="text-sm opacity-75">开发效率提升</div>
                </div>
            </div>
        </div>
    </div>

    <!-- 主要内容区域 -->
    <div class="max-w-6xl mx-auto px-6 py-12">
        <!-- 引言 -->
        <div class="bg-white rounded-2xl shadow-xl p-8 mb-12 fade-in">
            <p class="text-lg leading-relaxed text-gray-700 drop-cap">
                Maven 是 Java 生态中最常用的构建工具之一，但默认配置下，构建速度往往较慢，尤其是大型项目。在日常开发中，我们可以通过优化本地仓库管理、开启并行构建、使用增量编译等方式，极大提升 Maven 构建效率。
            </p>
        </div>

        <!-- 优化方法概览 -->
        <div class="mb-16 fade-in">
            <h2 class="text-3xl font-bold text-gray-800 mb-8 text-center">
                <i class="fas fa-tools mr-3 text-purple-600"></i>五大优化策略
            </h2>
            <div class="grid md:grid-cols-2 lg:grid-cols-3 gap-6">
                <div class="feature-card">
                    <div class="text-4xl text-purple-600 mb-4"><i class="fas fa-database"></i></div>
                    <h3 class="text-xl font-bold mb-2">优化本地仓库</h3>
                    <p class="text-gray-600">减少网络请求，使用 Nexus 私服</p>
                </div>
                <div class="feature-card">
                    <div class="text-4xl text-purple-600 mb-4"><i class="fas fa-layer-group"></i></div>
                    <h3 class="text-xl font-bold mb-2">启用并行构建</h3>
                    <p class="text-gray-600">充分利用多核 CPU</p>
                </div>
                <div class="feature-card">
                    <div class="text-4xl text-purple-600 mb-4"><i class="fas fa-sync-alt"></i></div>
                    <h3 class="text-xl font-bold mb-2">使用增量编译</h3>
                    <p class="text-gray-600">减少不必要的编译</p>
                </div>
                <div class="feature-card">
                    <div class="text-4xl text-purple-600 mb-4"><i class="fas fa-cog"></i></div>
                    <h3 class="text-xl font-bold mb-2">调整插件配置</h3>
                    <p class="text-gray-600">避免无用步骤，提高效率</p>
                </div>
                <div class="feature-card">
                    <div class="text-4xl text-purple-600 mb-4"><i class="fas fa-archive"></i></div>
                    <h3 class="text-xl font-bold mb-2">缓存依赖与构建结果</h3>
                    <p class="text-gray-600">提升重复构建性能</p>
                </div>
            </div>
        </div>

        <!-- 优化流程图 -->
        <div class="bg-gray-50 rounded-2xl p-8 mb-16 fade-in">
            <h2 class="text-2xl font-bold text-gray-800 mb-6 text-center">Maven 构建优化流程</h2>
            <div class="mermaid">
                graph LR
                    A[开始构建] --> B{检查本地仓库}
                    B -->|命中| C[加载依赖]
                    B -->|未命中| D[从私服下载]
                    D --> C
                    C --> E{增量编译检查}
                    E -->|有变更| F[并行编译]
                    E -->|无变更| G[跳过编译]
                    F --> H[执行测试]
                    G --> H
                    H --> I[打包部署]
                    I --> J[构建完成]
                    
                    style A fill:#667eea,stroke:#fff,color:#fff
                    style J fill:#10b981,stroke:#fff,color:#fff
                    style F fill:#f59e0b,stroke:#fff,color:#fff
            </div>
        </div>

        <!-- 详细内容 -->
        <div class="space-y-16">
            <!-- 1. 优化本地仓库 -->
            <section class="fade-in">
                <h2 class="text-3xl font-bold text-gray-800 mb-8 section-title">
                    1. 优化本地仓库
                </h2>
                
                <div class="bg-white rounded-xl shadow-lg p-8 mb-8">
                    <h3 class="text-xl font-semibold mb-4 text-gray-700">
                        <i class="fas fa-folder-open mr-2 text-purple-600"></i>1.1 设定合适的本地仓库路径
                    </h3>
                    <p class="text-gray-600 mb-4 leading-relaxed">
                        Maven 默认的本地仓库路径为 <span class="inline-code">~/.m2/repository</span>（Windows 下为 <span class="inline-code">C:\Users\用户名\.m2\repository</span>）。
                    </p>
                    <p class="text-gray-600 mb-4">如果你的磁盘 I/O 速度较慢，建议将本地仓库迁移到更快的 SSD 盘：</p>
                    <pre data-language="xml"><code>&lt;settings&gt;
  &lt;localRepository&gt;/mnt/ssd/maven-repo&lt;/localRepository&gt;
&lt;/settings&gt;</code></pre>
                    <div class="bg-blue-50 border-l-4 border-blue-500 p-4 mt-4">
                        <p class="text-blue-700"><i class="fas fa-lightbulb mr-2"></i>提示：使用 SSD 可以将依赖加载速度提升 3-5 倍</p>
                    </div>
                </div>

                <div class="bg-white rounded-xl shadow-lg p-8 mb-8">
                    <h3 class="text-xl font-semibold mb-4 text-gray-700">
                        <i class="fas fa-server mr-2 text-purple-600"></i>1.2 使用 Nexus 私服加速依赖下载
                    </h3>
                    <p class="text-gray-600 mb-4">
                        如果 Maven 每次都从中央仓库下载依赖，构建速度会受网络影响。建议企业内部搭建 Nexus 私服，然后修改 <span class="inline-code">settings.xml</span> 添加私服镜像：
                    </p>
                    <pre data-language="xml"><code>&lt;mirrors&gt;
  &lt;mirror&gt;
    &lt;id&gt;nexus&lt;/id&gt;
    &lt;mirrorOf&gt;*&lt;/mirrorOf&gt;
    &lt;url&gt;http://nexus.company.com/repository/maven-group/&lt;/url&gt;
    &lt;layout&gt;default&lt;/layout&gt;
  &lt;/mirror&gt;
&lt;/mirrors&gt;</code></pre>
                </div>